﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using PSE.AuditLogging.Client.Configuration;

namespace PSE.AuditLogging.ContingencyService.Configuration
{
    [ConfigurationCollection(typeof(LogSenderConfigurationSection), AddItemName = "logSender")]
    public class LogSenderConfigurationSectionCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new LogSenderConfigurationSection();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((LogSenderConfigurationSection)element).ProductId;
        }

        public new LogSenderConfigurationSection this[string key]
        {
            get
            {
                return (LogSenderConfigurationSection)BaseGet(key);
            }
            set
            {
                this.BaseRemove(key);
                this.BaseAdd(value);
            }
        }

        public void Add(LogSenderConfigurationSection item)
        {
            base.BaseAdd(item);
        }

        public void Remove(string productId)
        {
            if (base.BaseGet(productId) != null) //se existe
                base.BaseRemove(productId);
        }
    }
}
